<?php

use Phalcon\Mvc\Router,
    Phalcon\Mvc\Router\Group as RouterGroup;

/**
 * Errors Routing group
 */
$errorsRouting = new RouterGroup( array(
    'namespace' => 'Registro\Common\Controllers',
    'controller' => 'exceptions'
        ) );

$errorsRouting->setPrefix( '/exceptions' );
$errorsRouting->add( '[/]{0,1}', 'Exceptions::index' );
$errorsRouting->add( '/:action', 'Exceptions::1' );

/**
 * Auth Routing group
 */
$authRouting = new RouterGroup( array(
    'namespace' => 'Registro\Common\Controllers',
    'controller' => 'auth'
        ) );

$authRouting->setPrefix( '/auth' );
$authRouting->add( '[/]{0,1}', 'Auth::index' );
$authRouting->add( '/:action', 'Auth::1' );


$router = new Router();

$router->setDefaultModule( 'frontend' );
$router->setDefaultNamespace( 'Registro\Frontend\Controllers' );

$router->mount( $errorsRouting );
$router->mount( $authRouting );

/**
 * Backend
 */
$router->add( "/admin[/]{0,1}", array(
    'namespace' => 'Registro\Backend\Controllers',
    'module' => 'backend',
    'controller' => 1,
    'action' => 2,
) );

return $router;
